/*
 * IncFile1.h
 *
 * Created: 20.12.2012 00:15:30
 *  Author: clemens
 */ 


#ifndef LEDGFX_H_
#define LEDGFX_H_
#include <stdint.h> 
#include <avr/eeprom.h>

#define swap(a, b) { int16_t t = a; a = b; b = t; }
#define _width 1
#define _height 1	

//http://www.onlyfont.com/pixel_bitmap-99/5x5_pixel.html
//#define letter_a 11111 10011 10001 10001 11111b
/*#define letter_q 0b1111110001100011001111111
#define letter_0 0b00000000000011111100011111100000
#define letter_1 0b00000000000001000111110000000000
#define letter_2 0b00000000000010011101011100100000
#define letter_3 0b00000000000010001101011101100000
#define letter_4 0b00000000011001010101110001000000
#define letter_5 0b00000000000011101101011011100000
#define letter_6 0b00000000000011111101011011100000
#define letter_7 0b00000000000010000101111100000000
#define letter_8 0b00000000000011111101011111100000
#define letter_9 0b00000000000011100101001111100000
#define letter_A 0b00000000000001111101000111100000
#define letter_B 0b00000000000011111101010111000000
#define letter_C 0b00000000000001110100011000100000
#define letter_D 0b00000000000011111100011000101110
#define letter_E 0b00000000000011111101011010100000
#define letter_F 0b00000000000011111101001010000000
#define letter_G 0b00000000111010001101011011100000
#define letter_H 0b00000001111100100001001111100000
#define letter_I 0b00000000000010001111111000100000
#define letter_J 0b00000000001110001111111000000000
#define letter_K 0b00000000000011111001001101100000
#define letter_L 0b00000000000011111000010000100000
#define letter_M 0b00000001111101000001000100011111
#define letter_N 0b00000001111101000001001111100000
#define letter_O 0b00000000111010001100010111000000
#define letter_P 0b00000000000011111101001010011100
#define letter_Q 0b00000000111010001100010111000001
#define letter_R 0b00000001111110100101101110100000
#define letter_S 0b00000001110110101101011011100000
#define letter_T 0b00000001000010000111111000010000
#define letter_U 0b00000001111000001000011111000000
#define letter_V 0b00000001100000110000010011011000
#define letter_W 0b00000001110000011011000001111100
#define letter_X 0b00000001001101100011001001100000
#define letter_Y 0b00000001000001000001110100010000
#define letter_Z 0b00000001001110101110011000100000
#define letter_herz 0b00000000110010010010011001001100
#define letter_herz_fill 0b00000000110011110011111111001100
#define letter_play 0b00000001111100000111110111000100
#define letter_pause 0b00000000000011111000001111100000
#define letter_note_doppelt 0b00000000001111111100001001111111
#define letter_note_einzeln 0b00000000001100011111110100000100
#define letter_arrow_up 0b00000000010001000111110100000100
#define letter_arrow_down 0b00000000010000010111110001000100
#define letter_arrow_left 0b00000000010001110101010010000100
#define letter_arrow_right 0b00000000010000100101010111000100
#define letter_question 0b00000000000010000101011100000000
#define letter_exclamation 0b00000000000000000111010000000000
#define letter_ghost 0b00000000111110110111111011001111
#define letter_dots 0b00000000010000000001000000000100
#define letter_smiley 0b00000000001001001000010100100010
//#define letter_r 11111 10011 10001 10001 11111b
*/

/*
#define len_folge 40
uint32_t eemuster_folge[len_folge];
#define len_folge_2 80
uint32_t eemuster_folge_2[len_folge_2];
#define len_folge_fade 40
uint32_t eemuster_folge_fade[len_folge_fade];
#define len_bonvoyage 26
uint32_t eemuster_bonvoyage[len_bonvoyage];
#define len_orakel_start 8
uint32_t eemuster_orakel_start[len_orakel_start];
#define len_orakel 24
uint32_t eemuster_orakel[len_orakel];
#define len_arrows 8
uint32_t eemuster_arrows[len_arrows];

*/



struct CRGB {
	union {
		struct {
			union {
				
				uint8_t g;
				uint8_t green;
			};
			union {
				uint8_t r;
				uint8_t red;
				
			};
			union {
				uint8_t b;
				uint8_t blue;
			};
		};
		uint8_t raw[3];
	};
	
	
}	;

struct CRGB led[_width][_height]; //3D 

/*
uint8_t red[20][20];
uint8_t green[20][20];
uint8_t blue[20][20];
*/
/*
uint8_t getred(int8_t x,int8_t x);
uint8_t getgreen(int8_t x,int8_t x);	
uint8_t getblue(int8_t x,int8_t x)
*/	
void drawPixel(int8_t x, int8_t y, uint8_t c_red, uint8_t c_green, uint8_t c_blue);
void drawLine(int8_t x0, int8_t y0, int8_t x1, int8_t y1, uint8_t c_red, uint8_t c_green, uint8_t c_blue);
void led_out(void);

void getRGB(uint16_t hue, uint8_t sat, uint8_t val, uint8_t colors[3]);

void invertDisplay();

// these are 'generic' drawing functions, so we can share them!

 void drawFastVLine(int16_t x, int16_t y, int16_t h, uint8_t c_red, uint8_t c_green, uint8_t c_blue);
 void drawFastHLine(int16_t x, int16_t y, int16_t w, uint8_t c_red, uint8_t c_green, uint8_t c_blue);
 void drawRect(int16_t x, int16_t y, int16_t w, int16_t h,
uint8_t c_red, uint8_t c_green, uint8_t c_blue);
 void fillRect(int16_t x, int16_t y, int16_t w, int16_t h,
uint8_t c_red, uint8_t c_green, uint8_t c_blue);
 void fillScreen(uint8_t c_red, uint8_t c_green, uint8_t c_blue);

uint32_t getPixel(int8_t x,int8_t y);

void drawCircle(int16_t x0, int16_t y0, int16_t r, uint8_t c_red, uint8_t c_green, uint8_t c_blue);
void drawCircleHelper(int16_t x0, int16_t y0,
int16_t r, uint8_t cornername, uint8_t c_red, uint8_t c_green, uint8_t c_blue);
void fillCircle(int16_t x0, int16_t y0, int16_t r, uint8_t c_red, uint8_t c_green, uint8_t c_blue);
void fillCircleHelper(int16_t x0, int16_t y0, int16_t r,
uint8_t cornername, int16_t delta, uint8_t c_red, uint8_t c_green, uint8_t c_blue);

void drawTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1,
int16_t x2, int16_t y2, uint8_t c_red, uint8_t c_green, uint8_t c_blue);
void fillTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1,
int16_t x2, int16_t y2, uint8_t c_red, uint8_t c_green, uint8_t c_blue);
void drawRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h,
int16_t radius, uint8_t c_red, uint8_t c_green, uint8_t c_blue);
void fillRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h,
int16_t radius, uint8_t c_red, uint8_t c_green, uint8_t c_blue);
/*
void drawBitmap(int16_t x, int16_t y,
const uint8_t *bitmap, int16_t w, int16_t h,
uint8_t c_red, uint8_t c_green, uint8_t c_blue);
*/
void drawChar(int8_t x_offset, uint32_t letter, uint8_t c_red, uint8_t c_green, uint8_t c_blue);


/*
void setCursor(int16_t x, int16_t y);
void setTextColor(uint16_t c);
void setTextColor(uint16_t c, uint16_t bg);
void setTextSize(uint8_t s);
void setTextWrap(boolean w);
*/

//int16_t height(void);
//int16_t width(void);

void setRotation(uint8_t r);
uint8_t getRotation(void);

//protected:
//int16_t  WIDTH, HEIGHT;   // this is the 'raw' display w/h - never changes
//int16_t  _width, _height; // dependent on rotation
//int16_t  cursor_x, cursor_y;
//uint16_t textcolor, textbgcolor;
//uint8_t  textsize;
uint8_t  rotation;
//boolean  wrap; // If set, 'wrap' text at right edge of display



#endif /* INCFILE1_H_ */